﻿Public Class Planilla 
    Public Sub Mostrar()
        If guardar.Enabled = False Then
            guardar.Enabled = True
            cancelar.Enabled = True
            agregar.Enabled = False
            modificar.Enabled = False
            eliminar.Enabled = False
            imprimir.Enabled = False
            PanelArriba.Enabled = True
            PanelMedio.Enabled = True
            PanelAbajo.Enabled = False
        Else
            cancelar.Enabled = False
            guardar.Enabled = False
            agregar.Enabled = True
            Modificar.Enabled = True
            Eliminar.Enabled = True
            imprimir.Enabled = True
            PanelArriba.Enabled = False
            PanelMedio.Enabled = False
            PanelAbajo.Enabled = True
        End If
    End Sub
    Private Sub PlanillasBindingNavigatorSaveItem_Click(sender As System.Object, e As System.EventArgs) Handles PlanillasBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.PlanillasBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.DbFireAndIceDataSet)
    End Sub

    Private Sub Planilla_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'DbFireAndIceDataSet.empleados' table. You can move, or remove it, as needed.
        Me.EmpleadosTableAdapter.Fill(Me.DbFireAndIceDataSet.empleados)
        'TODO: This line of code loads data into the 'DbFireAndIceDataSet.planillasdetalle' table. You can move, or remove it, as needed.
        Me.PlanillasdetalleTableAdapter.Fill(Me.DbFireAndIceDataSet.planillasdetalle)
        'TODO: This line of code loads data into the 'DbFireAndIceDataSet.planillas' table. You can move, or remove it, as needed.
        Me.PlanillasTableAdapter.Fill(Me.DbFireAndIceDataSet.planillas)
    End Sub
    Private Sub PlanillaDetalleBindingNavigatorSaveItem_Click(sender As System.Object, e As System.EventArgs) Handles PlanillasBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.PlanillasdetalleBindingSource.EndEdit()
        Me.PlanillasdetalleTableAdapter.Fill(Me.DbFireAndIceDataSet.planillasdetalle)
    End Sub




    Private Sub SimpleButton1_Click_1(sender As System.Object, e As System.EventArgs) Handles SimpleButton1.Click
        '    Dim fecha1 As Date = Date.Now
        '    Dim fecha2 As Date = Date.Now
        '    Dim v1 As Integer = Convert.ToUInt32(IdplanillaTextBox1.Text)
        '    Dim v2 As Integer = Convert.ToUInt32(IdempleadoGridLookUpEdit.Text)
        '    Dim v3 As Decimal = Convert.ToDecimal(TotaldeduccionTextBox.Text)
        '    Dim v4 As Decimal = Convert.ToDecimal(TotalhorasextraTextBox.Text)
        '    Dim v5 As Decimal = Convert.ToDecimal(SueldofinalTextBox.Text)
        '    'PlanillasDetalleBindingNavigatorSaveItem.PerformClick()
        '    PlanillasTableAdapter.InsertPlanillaQuery(IdplanillaTextBox.Text, fecha1, fecha2, ObservacionTextBox.Text)
        '    PlanillasdetalleTableAdapter.InsertPlanillsaDetalleQuery(v1, v2, v3, v4, v5, ObservacionTextBox1.Text)
    End Sub


    Private Sub IdempleadoGridLookUpEdit_EditValueChanged(sender As System.Object, e As System.EventArgs) Handles IdempleadoGridLookUpEdit.EditValueChanged
        'primero condicionamos que el lookup no esté nulo. porque cuando el form carga no se ha n llenado los tableadapters tonces:
        If Not IsDBNull(IdempleadoGridLookUpEdit) Then  'si no es nulo el lookupedit
            TextEdit1.EditValue = IdempleadoGridLookUpEdit.GetColumnValue("direccion")
            'vamos a ver
        End If

    End Sub
End Class